﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

class Phones
{
    static void Main()
    {
        TextReader fileReader = new StreamReader("example.txt");
        using (fileReader)
        {
            string content = fileReader.ReadToEnd();
            Regex phoneRegex = new Regex(@"\(\+[1-9]{3}\)\s[0-9]{3}\s[0-9]{3}-[0-9]{3}");
            Match matchPhone = phoneRegex.Match(content);
            TextWriter fileWriter = new StreamWriter("phones.txt");
            using (fileWriter)
            {
                while (matchPhone.Success)
                {
                    fileWriter.WriteLine(matchPhone.Value);
                    matchPhone = matchPhone.NextMatch();
                }
            }
        }
    }
}
